Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use platformdirs #7300

Merged
merged 20 commits into from
Feb 9, 2023
Merged

Conversation

RayyanAnsari
Copy link
Contributor

@RayyanAnsari RayyanAnsari commented Jan 24, 2023

fixes #7281

@RayyanAnsari RayyanAnsari force-pushed the borg-platformdirs branch 2 times, most recently from 8500282 to 5659b9d Compare January 24, 2023 18:29
@ThomasWaldmann ThomasWaldmann added this to the 2.0.0b5 milestone Jan 30, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jan 30, 2023

Codecov Report

Merging #7300 (f29ff12) into master (7ffd877) will decrease coverage by 0.13%.
The diff coverage is 80.00%.

❗ Current head f29ff12 differs from pull request most recent head 516c070. Consider uploading reports for the commit 516c070 to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #7300      +/-   ##
==========================================
- Coverage   83.62%   83.50%   -0.13%     
==========================================
  Files          67       67              
  Lines       11668    11679      +11     
  Branches     2122     1982     -140     
==========================================
- Hits         9757     9752       -5     
- Misses       1342     1355      +13     
- Partials      569      572       +3     
Impacted Files Coverage Δ
src/borg/helpers/fs.py 79.48% <79.31%> (-1.24%) ⬇️
src/borg/helpers/__init__.py 100.00% <100.00%> (ø)
src/borg/fuse_impl.py 30.76% <0.00%> (-23.08%) ⬇️
src/borg/archiver/create_cmd.py 78.16% <0.00%> (-0.32%) ⬇️
src/borg/archive.py 84.09% <0.00%> (-0.19%) ⬇️
src/borg/repository.py 83.11% <0.00%> (-0.09%) ⬇️
src/borg/archiver/debug_cmd.py 74.12% <0.00%> (ø)
src/borg/archiver/benchmark_cmd.py 60.44% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Comment on lines 614 to 615
assert get_config_dir(legacy=False) == get_config_dir(legacy=True)
# TODO fails on macOS: assert '/Users/tw/Library/Preferences/borg' == '/Users/tw/.config/borg'
Copy link
Member

@ThomasWaldmann ThomasWaldmann Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on macOS, it looks like platformdirs uses a different default: not ~/.config/<appname>.

this might affect a lot of macOS borg users (defaults, nothing special here).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on Linux, this works ok.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on cygwin, this works ok.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

win32 fail: assert 'C:/Users/runneradmin/AppData/Local/borg/borg' == 'D:\a\_temp\msys64\home\runneradmin/.config/borg'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it is using the HOME env var, which inside MSYS2 is set to the home directory of the MSYS2 installation.

>>> os.path.expanduser("~")
'C:/Users/Rayyan'
>>> os.environ.get("HOME")
'C:\\msys64\\home\\Rayyan'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i excluded that "legacy compat test" on win32, no need to have it there.

BTW, that .../Local/borg/borg path is correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RayyanAnsari seen this?

@ThomasWaldmann
Copy link
Member

On native win32, guess we can ignore legacy vs. non-legacy compatibility as nobody uses borg < 2 there.

@borgbackup borgbackup deleted a comment from RayyanAnsari Feb 3, 2023
@ThomasWaldmann ThomasWaldmann changed the title Use platformdirs on win32 use platformdirs Feb 3, 2023
@ThomasWaldmann ThomasWaldmann marked this pull request as ready for review February 4, 2023 00:07
there is no old borg < 2.0 there anyway.
@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented Feb 4, 2023

Test run looks good.

@RayyanAnsari maybe give the whole PR a review, please.

Are the tests complete, do they make sense? Something missing?

src/borg/testsuite/helpers.py Outdated Show resolved Hide resolved
src/borg/testsuite/helpers.py Outdated Show resolved Hide resolved
@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented Feb 6, 2023

Needs requirement: platformdirs >=3.0.0, <4.0.0 (and let's hope they don't break it without increasing major).

I'll fix the requirement...

we don't want to suddenly/unexpectedly break stuff for borg users
just because platformdirs does a breaking release.

at platformdirs 2.0.0 macOS config dir changed.
at platformdirs 3.0.0 macOS config dir changed again.
at platformdirs 4.0.0 (future) - who knows?
@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented Feb 6, 2023

TODO: #7332

@ThomasWaldmann
Copy link
Member

@RayyanAnsari merged! thanks for working on this!

nain-F49FF806 added a commit to nain-F49FF806/borg that referenced this pull request Mar 18, 2023
Make sure the result of get_cache_dir
matches pre and post borgbackup#7300 where desired
nain-F49FF806 added a commit to nain-F49FF806/borg that referenced this pull request Mar 29, 2023
Make sure the result of get_cache_dir
matches pre and post borgbackup#7300 where desired
ThomasWaldmann pushed a commit that referenced this pull request Mar 29, 2023
fix config dir compatibility issue, fixes #7445

- add tests
- make sure the result of get_cache_dir matches pre and post #7300 where desired
- harmonize implementation of config_dir_compat and cache_dir_compat tests

Co-authored-by: nain <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

borg2: use platformdirs python package?
3 participants